package com.jiayang.webview;

import android.annotation.SuppressLint;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * @ClassName MyContentProvider
 * @Author JIAYANG
 * @Date 2022/5/11 10:29
 * @Email 1354856871@qq.com
 */
public class MyContentProvider extends ContentProvider {

    @SuppressLint("LongLogTag")
    @Nullable
    @Override
    public Bundle call(@NonNull String authority, @NonNull String method, @Nullable String arg, @Nullable Bundle extras) {
//        Log.d("com.example.call", String.format("Provider#call(%s, %s)", method, arg));
//        Log.i("com.example.call", String.format("Provider#call uid (%s)", Binder.getCallingUid()));
//        Log.i("com.example.call", String.format("Provider#call pid (%s)", Binder.getCallingPid()));
//        Log.i("com.example.call", String.format("Provider#call package (%s)", getContext().getPackageManager().getNameForUid(Binder.getCallingUid())));
//        Context mContext = getContext();
//
//        if ("Method_read".equals(method)) {
//            if (mContext.checkCallingPermission("com.example.author.read_permission") == PackageManager.PERMISSION_GRANTED) {
//                Log.d("com.example.call Method_read2", "PackageManager.PERMISSION_GRANTED");
//            }
//            else {
//                Log.d("com.example.call Method_read", "PackageManager.PERMISSION_DENIED");
//            }
//        }
//        if ("Method_write".equals(method)) {
//            if (mContext.checkCallingPermission("com.example.author.write_permission") == PackageManager.PERMISSION_GRANTED) {
//                Log.d("com.example.call Method_write", "PackageManager.PERMISSION_GRANTED");
//            } else {
//                Log.d("com.example.call Method_write", "PackageManager.PERMISSION_DENIED");
//            }
//        }
        Bundle bundle=new Bundle();
        bundle.putString("All","OK");
        return bundle;

    }

    @Override
    public boolean onCreate() {
        return false;
    }

    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
        return null;
    }

    @Nullable
    @Override
    public String getType(@NonNull Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
        return null;
    }

    @Override
    public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }

    @Override
    public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }
}
